package LeetCode.leetcode;

import domain.ListNode;

/**
 * 删除排序列表中的重复元素
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/25
 * @time: 18:35
 */
public class Test83删除排序链表中的重复元素 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) {
            return head;
        }
        ListNode p = head;
        while (p != null) {
            ListNode temp = p.next;
            while (temp != null && temp.val == p.val) {
                temp = temp.next;
            }
            p.next = temp;
            p = temp;
        }
        return head;

    }
}
